using System;
using System.Collections.Generic;
using System.Text;

namespace IWMAG.Scripting.Compiler {
    public struct Lexeme {
        public Token Type;
        public int Line;
        public int Column;
        public int IntData;
        public double RealData;
        public string StringData;

        public Lexeme(Token type, Lexer context) {
            Type = type;
            Line = context.Line;
            Column = context.Column;
            IntData = 0;
            RealData = 0.0;
            StringData = null;
        }

        public Lexeme(Token type, Lexer context, int num) {
            Type = type;
            Line = context.Line;
            Column = context.Column;
            IntData = num;
            RealData = 0.0;
            StringData = null;
        }

        public Lexeme(Token type, Lexer context, double num) {
            Type = type;
            Line = context.Line;
            Column = context.Column;
            IntData = 0;
            RealData = num;
            StringData = null;
        }

        public Lexeme(Token type, Lexer context, string str) {
            Type = type;
            Line = context.Line;
            Column = context.Column;
            IntData = 0;
            RealData = 0.0;
            StringData = str;
        }

        public override string ToString() {
            string s = Type.ToString();
            if (Type == Token.IntValue)
                return String.Format("{0}({1})", s, IntData);
            if (Type == Token.RealValue)
                return String.Format("{0}({1})", s, RealData);
            if (Type == Token.StringValue)
                return String.Format("{0}(\"{1}\")", s, StringData);
            if (Type == Token.Ident)
                return String.Format("{0}({1})", s, StringData);
            return s;

        }
    }
}